<template>
  <div>
    <el-container style="height: calc(100vh);">
      <div class="sac-aside">
        <div class="logo">
          管理员，{{nickName}}
        </div>
        <div class="menu">
          <el-menu
            class="el-menu-vertical-demo"
            router
            background-color="#2C2854"
            text-color="#A5A1C8"
            :unique-opened="true"
            :default-active="defaultActive"
          >
            <el-submenu index="1">
              <template slot="title">
                <i class="common-icon icon-member"></i>
                <span>用户管理</span>
              </template>
              <el-menu-item index="1-1" route="/user/userList">用户中心</el-menu-item>
            </el-submenu>
          </el-menu>
        </div>
      </div>
      <el-container class="sys-box">
        <el-header>
          <div class="header-box">
            <ul class="stati">
              <li class="coustomer">
                <span>后台管理系统</span>
              </li>
              <li class="usrName_logout" style="color:#FF3828;padding-right:0" @click="goLogout">
                <i></i>
                退出
              </li>
              <li class="usrName_logout" @click="changePwd">修改密码</li>
            </ul>
          </div>
        </el-header>
        <el-main>
          <transition name="el-zoom-in-center">
            <keep-alive :exclude="/NotAlive$/">
              <router-view class="router-view"></router-view>
            </keep-alive>
          </transition>
        </el-main>
      </el-container>
    </el-container>
    <el-dialog
      title="修改密码"
      :visible.sync="centerDialogVisible"
      width="30%"
      @close="closeDialog"
      close-on-click-modal
      center>
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="原密码">
          <el-input size="small" type="password" v-model="form.passwordOld"></el-input>
        </el-form-item>
        <el-form-item label="新密码">
          <el-input size="small" type="password" v-model="form.passwordNew"></el-input>
        </el-form-item>
        <el-form-item label="确认密码">
          <el-input size="small" type="password" v-model="form.passwordAgain"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="centerDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="sureChangePwd">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import md5 from 'js-md5'

export default {
  name: "index",
  data() {
    return {
      menuList: [],
      account: "",
      defaultActive:'1-1',
      nickName:'张三',
      centerDialogVisible:false,
      form:{},
    };
  },
  computed:{
    
  },
  methods: {
    goLogout() {
      this.$confirm("是否退出登录", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$notify.success({
          title: '提示',
          message: '登出成功',
        });
        })
    },
    changePwd(){
      this.centerDialogVisible = true;
    },
    sureChangePwd(){
      if(!this.form.passwordOld || !this.form.passwordNew || !this.form.passwordAgain){
        this.$notify.error({
          title: '提示',
          message: '输入不能为空！',
        });
        return
      }
      let obj = {
        passwordOld:md5(this.form.passwordOld),
        passwordNew:md5(this.form.passwordNew),
        passwordAgain:md5(this.form.passwordAgain)
      }
      // 调接口
        this.$notify.success({
          title: '提示',
          message: '修改成功！',
        });
     
    },
    closeDialog(){
      this.form = {};
    }
  },
 
};
</script>
<style lang="less" scoped>
span {
  font-size: 16px;
}
li {
  font-size: 16px;
}
.sac-aside {
  height: 100%;
  width: 200px;
  overflow-y: auto;
  .logo {
    height: 60px;
    background: #3F3984;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color:#fff;
    font-size: 14px;
    img {
      height: 35px;
    }
    span {
      margin-left: 10px;
      font-size: 14px;
      color: #fff;
      font-weight: bold;
    }
  }
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    height: calc(100vh - 60px);
    border: none;
  }

  .common-icon {
    background-size: 100% !important;
    display: inline-block;
    margin: 0 5px;
  }
  .icon-member {
    background: url("~@/assets/member.png") no-repeat;
    width: 17px;
    height: 20px;
  }
}
.el-main {
  height: 100%;
  background: #eff2f6;
  padding: 0px;
  overflow: hidden;
  min-width: 1150px;
  > div {
    background: #fff;
    height: 100%;
    width: 100%;
    overflow-y: auto;
  }
}
.sys-box {
  width: calc(100% - 200px);
}
.el-header {
  background: #827EB6;
  .header-box {
    height: 100%;
    .back_icon {
      display: inline-block;
      width: 7px;
      height: 7px;
      background: #324253;
      border-radius: 50%;
      float: left;
      margin-top: 27px;
    }
    .stati {
      height: 100%;
      overflow: hidden;
      li {
        float: left;
        margin-left: 30px;
        height: 100%;
        line-height: 60px;
        color: #324253;
        font-size: 16px;
        &:nth-child(1) {
          margin-left: 10px;
        }
        &.download{
          position: relative;
          img{
            vertical-align: middle;
          }
          >span{
            display: inline-block;
            position: absolute;
            top: 20px;
            font-size: 12px;
            color: blue;
            line-height: 15px;
            margin-left: 60px;
          }
        }
        &.usrName_logout {
          float: right;
          font-size: 16px;
          padding: 0 18px;
          // border-left: 1px solid #524E8C;
          margin-left: 0;
          cursor: pointer;
          position: relative;
          
          i {
            display: inline-block;
            width: 18px;
            height: 18px;
            vertical-align: middle;
            background: url("../../assets/logout.png") no-repeat center / 100%
              100%;
          }
          &.needBorder{
            &::before{
            content: '';
            display: inline-block;
            width: 1px;
            height: 37px;
            background: #524E8C;
            margin-top: 12px;
            position: absolute;
            right: 0;
          }
          }
        }
        &.coustomer{
          span{
            font-size: 20px;
            margin-left: 15px;
            color: #fff;
          }
        }
      }
    }
  }
}

</style>
